package org.henau.TaskLogger;

// 3. 日志装饰器
public class TaskLogger implements Task {
    private Task task;
    private Logger logger;

    public TaskLogger(Task task, Logger logger) {
        this.task = task;
        this.logger = logger;
    }

    @Override
    public void execute() {
        logger.log("任务开始: " + task.getClass().getSimpleName());
        long start = System.currentTimeMillis();

        task.execute();

        long duration = System.currentTimeMillis() - start;
        logger.log("任务完成! 耗时: " + duration + "ms");
    }
}